package com.zrt.springboot.utils;

import com.zrt.springboot.entity.River;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Random;

@Component
public class Simulated {

    public River RiverMonitorBySensorId(String sensorId){
        //随机生成河流的深度
        double depth = new Random().nextDouble();
        depth = depth * 3 +1;
        BigDecimal b = new BigDecimal(depth);
        depth = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
        //写入实体类

        River river = new River(0,sensorId,depth,null);
        return river;
    }


}
